package com.daisuxia.rongbao.utils;

import com.alibaba.fastjson.JSON;

import java.util.Map;

public class ReapalSubmit {
	/**
     * 发送请求
     * @return 返回结果
     */
	public static String buildSubmit(Map<String, String> para,String merchant_id, String url) throws Exception {
        //生成签名
		String mysign = Md5Utils.BuildMysign(para, PropertiesUtil.get("key"));
        para.put("sign", mysign);
        para.put("sign_type", "MD5");
        //将map转化为json 串
		String json = JSON.toJSONString(para);
		//加密数据
		System.out.println("json:"+json);
		Map<String, String> maps = Decipher.encryptData(json);
		maps.put("merchant_id", merchant_id);
		//发送请求 并接收
		System.out.println(url);
		String post = HttpClientUtil.post(url, maps);
		return post;
	}
	
	/**
     * 融托富 -发送请求
     * @return 返回结果
     */
	public static String buildSubmitForRtf(Map<String, String> para,String merchant_id, String url) throws Exception {
        //生成签名
		String reqData = para.get("reqData");
		String mysign = Md5Utils.md5(reqData+ PropertiesUtil.get("key"),"utf-8");
        para.put("sign", mysign);
		//发送请求 并接收
		System.out.println(url);
		String post = HttpClientUtil.post(url, para);
		return post;
	}
	
	
}
